package com.example.aboutwork.tests;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.junit.Test;

import java.util.HashMap;
import java.util.Set;

public class TestMap {

    @Test
    public void map的keySet移除操作会影响到map本身() {
        HashMap<Object, Object> map = Maps.newHashMap();
        map.put(1, 1);
        map.put(2, 2);
        Set<Object> objects = map.keySet();
        Lists.newArrayList(1).forEach(objects::remove);
        System.err.println(map); //{2=2}
    }

}
